
tempfile main
foreach y of numlist 2007(1)2008 {
	global y `y'
	use ape* siren s_brut comt using "${tmp}\dads${y}", clear
	gduplicates drop
	drop if substr(siren,1,1) == "P"
	drop if mi(apen)
	gen year = ${y}
	cap append using `main'
	save `main', replace
	}
gduplicates drop
bys siren comt: egen naf_rev1 = mode(apet) if strlen(apet) == 4, minmode
bys siren comt: egen naf_rev2 = mode(apet) if strlen(apet) == 5, minmode
bys siren (naf_rev1): replace naf_rev1 = naf_rev1[_N]
bys siren (naf_rev2): replace naf_rev2 = naf_rev2[_N]
bys naf_rev1 : egen tot_sal_rev1 = sum(s_brut)
bys naf_rev1 naf_rev2: egen tot_sal_rev1rev2 = sum(s_brut)
keep siren comt naf_rev? tot_sal*
gduplicates drop
gen share = tot_sal_rev1rev2 / tot_sal_rev1
drop tot_sal*
compress
destring siren, replace force
drop if mi(naf_rev1) | mi(naf_rev2) | mi(siren)
save "${data}/Utils/SirenCom_NAF_rev12_dads", replace